Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support commonjs default export #1225

Merged
merged 1 commit into from
May 11, 2023
Merged

Conversation

zmedgyes
Copy link
Contributor

What's Changing and Why

Adjusted the add-module-exports babel-plugin configuration to create a synthetic default export for CommonJS modules.
In partice, it only appends a module.exports.default = exports.default; to every packages/*/dist/index.js.

It would be required to support the custom modular configuration of Jimp for CommonJS Typescript projects, where the esModuleInterop compiler-option cannot be turned on.

With those settings, the import Jimp from 'jimp'; resolves to const Jimp = require('jimp').default;.

This will result in a runtime error, as previously the packages didn't have default property on their CommonJS export.

For the main distribution of Jimp, this could have been bypassed by using namespace import (import * as Jimp from 'jimp';). This is possible as the CommonJS module export for the jimp package is an object.
However the namespace importing wouldn't work for the modular packages, as their CommonJS export is a function, which is not supported by the ES6.

What else might be affected

This change shouldn't have any side-effects, as it is only affecting the method of distribution and is completely additive.

Tasks

  • Add tests
  • Update Documentation
  • Update jimp.d.ts
  • Add SemVer Label

@github-actions
Copy link
Contributor

🚀 PR was released in v0.22.9 🚀

@github-actions github-actions bot added the released This issue/pull request has been released. label Jul 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released This issue/pull request has been released.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants